package com.ayoka.mvp;

import com.ayoka.base.BasePresenter;
import com.ayoka.base.IBaseView;
import com.ayoka.bean.BaseResponse;
import com.ayoka.bean.UserInfoBean;
import com.ayoka.bean.UserInformation;
import com.ayoka.http.API;
import com.ayoka.http.OkHttpListener;

/**
 * Created by gabriel on 2017/3/5.
 */

public interface MineMVP {

    interface MineModel {

    }

    interface IMineView extends IBaseView {

        void configUserInfo();
    }

    class MinePresenter extends BasePresenter<IMineView> {

        public void getUserInfo() {
            API.getUserInformation(this, new OkHttpListener<BaseResponse<UserInfoBean>>() {
                @Override
                public void onSuccess(BaseResponse<UserInfoBean> response) {
                    if (!isAttached()) return;
                    mViewRef.get().hideWaitDialog();
                    UserInformation.getInstance().user_info = response.data;
                    UserInformation.save();
                    mViewRef.get().configUserInfo();
                }

                @Override
                public void onFailure(int errorCode, String errorMessage) {
                    if (!isAttached()) return;
                    mViewRef.get().hideWaitDialog();
                    mViewRef.get().showToast(errorMessage);
                }
            });
        }

    }

}
